#ifndef POKEMON_H
#define POKEMON_H

#include <QObject>
#include <QPixmap>
#include <QList>
#include <QString>

#include <QTimer>

// 元素类型
enum class Element {
    None = 0,
    Water = 1,
    Grass = 2,
    Fire = 3,
    Steel = 4,
    Rock = 5
};

// 前向声明
class Pokemon;

// 元素相克计算
float getElementEffectiveness(Element attacker, Element defender);

// 技能基类
class Skill : public QObject {
    Q_OBJECT
public:
    Skill(QString name, int power, Element element);

    QString getName() const { return m_name; }
    int getPower() const { return m_power; }
    Element getElement() const { return m_element; }

    virtual int calculateDamage(Pokemon* user, Pokemon* target);
    virtual void use(Pokemon* user, Pokemon* target);

signals:
    void skillUsed(QString message);

protected:
    QString m_name;
    int m_power;
    Element m_element;
};

// 具体技能声明


// 宝可梦类
class Pokemon : public QObject {
    Q_OBJECT
public:
    Pokemon(QString name, int hp, int attack, int defense, Element element, QString imagePath);

    // 属性访问
    QString getName() const { return m_name; }
    int getHP() const { return m_hp; }
    int getMaxHP() const { return m_maxHP; }
    Element getElement() const { return m_element; }
    QPixmap getImage() const { return m_image; }
    bool isAlive() const { return m_hp > 0; }

    // 技能管理
    void addSkill(Skill* skill);
    QList<Skill*> getSkills() const { return m_skills; }

    // 战斗方法
    void takeDamage(int damage);
    void useSkill(int index, Pokemon* target);

signals:
    void hpChanged(int currentHP, int maxHP);
    void fainted();

private:
    QString m_name;
    int m_hp, m_maxHP, m_attack, m_defense;
    Element m_element;
    QPixmap m_image;
    QList<Skill*> m_skills;
};

#endif // POKEMON_H
